package com.sb.registration.component.service;

import java.io.IOException;

import com.sb.registration.component.exceptions.DatastoreSystemException;
import com.sb.registration.component.exceptions.UserAlreadyExistsException;
import com.sb.registration.component.exceptions.UserDoesNotExistException;
import com.sb.registration.component.model.UserRegistrationServiceResult;
import com.sb.registration.component.model.UserWrapper;

/**
 * This interface defines service for performing user registration operations
 * 
 * @author gautam.amitkumar@gmail.com
 *
 */
public interface UserRegistrationManager {
	
	/**
	 * Method to register/add users into xml data repository
	 * 
	 * @param userData
	 * @throws UserAlreadyExistsException
	 * @throws DatastoreSystemException
	 */
	UserRegistrationServiceResult addUser(UserWrapper userData);
	
    /**
     * Method to update existing users
     * 
     * @param userData
     * @throws DatastoreSystemException
     * @throws UserDoesNotExistException
     */
	UserRegistrationServiceResult updateUser(UserWrapper user);
	
    /**
     * Method to delete existing users based on email id provided.
     * 
     * 
     * @param emailId
     * @throws DatastoreSystemException
     * @throws UserDoesNotExistException
     */
	UserRegistrationServiceResult deleteUser(UserWrapper userData);
	
	/**
	 * Method to delete existing users based on instance of user provided
	 * 
	 * @param emailId
	 * @throws DatastoreSystemException
	 * @throws UserDoesNotExistException
	 */
	UserRegistrationServiceResult deleteUser(String emailId);
	
	
    /**
     * Method to return all users available in the repository
     * 
     * @return List<UserWrapper>
     */
	UserRegistrationServiceResult fetchAllUsers();
	
    /**
     * Method to retrieve user on the basis of email id provided.
     * 
     * @param emailId
     * @return UserWrapper
     */
	UserRegistrationServiceResult getUser(String emailId);
	
    /**
     * Method to clear all existing users from the repository
     * 
     * @throws IOException
     * @throws DatastoreSystemException
     */
	UserRegistrationServiceResult clearAll();

}
